var http = require('http.js')
// 首页统计数据、图片
const statistic = () => {
  var url = 'common/statistic'
  // http.config.loadtext = 'sdsdsdsdsdsdsd'
  return http.getReq(url)
}
//行业类别
const industry = (data) => {
  var url = 'common/industry'
  return http.postReq(url, data)
}
//
const uploadimg = (imgfile) => {
  var url = 'common/upload'
  return http.uploadFile(url, imgfile)
}

//微信支付成功回调pay/sucesss
const pay_sucesss = (order_id, table) => {
  var url = 'pay/sucesss'
  return http.getReq(url, {
    order_id: order_id,
    table: table
  })
}
// 微信支付：小程序调起支付数据签名字段获取 pay/get_params
const paySucesss = (js_code, id, type, money) => {
  var url = 'pay/get_params'
  var data = {}
  switch (type) {
    case 'circle':
      data = {
        type: 'circle',
        circle_id: id
      }
      break;
    case 'gratuity':
      data = {
        type: 'gratuity',
        circle_id: id,
        money: money
      }
      break;
    case 'vip':
      data = {
        type: 'vip',
        vip_id: id,
        money: money
      }
      break;
    case 'card_top':
      data = {
        type: 'card_top',
        card_id: id
      }
      break;
    case 'cz':
      data = {
        type: 'cz',
        money: money
      }
      break;
  }
  data = Object.assign(data, {
    js_code: js_code,
  })
  return http.getReq(url, data)
}


//获取accesstoken  
const getAccessToken = (shopid) => {
  var url = 'token/getAccessToken'
  return http.getReq(url, {
    shopid,
  })
}
module.exports = {
  uploadimg,
  paySucesss,
  pay_sucesss,
  getAccessToken,
}